package com.framework.bdf4j.msg.sender;

import java.util.ArrayList;
import java.util.List;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.framework.bdf4j.msg.constant.PublicConstant;
import com.framework.bdf4j.msg.entity.dto.SysMessagesSaveDTO;
import com.framework.bdf4j.msg.entity.vo.SysMsgResultVO;
import com.framework.bdf4j.msg.entity.vo.SysUserVO;

/**
 * 短息发送器
 *
 * @author shan.deng
 * @date 2020-07-15 16:06:44
 */
@Component("smsMessageSender")
public class SmsSender extends Sender {

    /**
     * 发送短信
     * @param sysMessagesSaveDTO
     */
    @Override
    @Async
    public void send(Integer msgId, SysMessagesSaveDTO sysMessagesSaveDTO, List<SysUserVO> users) throws RuntimeException{
        List<SysMsgResultVO> resultVOS = new ArrayList<>();
        users.stream().forEach(user -> {
            SysMsgResultVO sysMsgResultVO = new SysMsgResultVO(user.getUserId(), PublicConstant.MSG_SEND_RESULT_FAILURE_CODE,PublicConstant.NO_SMS_SUPPORT_TEXT,PublicConstant.SEND_TYPE_SMS);
            resultVOS.add(sysMsgResultVO);
        });
        recordResult(msgId,resultVOS);
    }
}
